import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/*
 * Author: Anthony Fleshner
 * 
 * Use actionPerformed "if" statements to update the Link positions in "robot".
 */

class ButtonListener implements ActionListener {
 
    RobotComponent robot;
    
    ButtonListener(RobotComponent rob){
        this.robot = rob;
    }

  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("3 CW")) {
      System.out.println("Button1 has been clicked");
      robot.rotate3CW();
    }
    else if (e.getActionCommand().equals("2 CW")) {
        System.out.println("Button3 has been clicked");
        robot.rotate2CW();
      }
    else if (e.getActionCommand().equals("Left")) {
        System.out.println("Button5 has been clicked");
        robot.moveLeft();
      }
    else if (e.getActionCommand().equals("3 CCW")) {
        System.out.println("Button2 has been clicked");
        robot.rotate3CCW();
      }
    else if (e.getActionCommand().equals("2 CCW")) {
        System.out.println("Button4 has been clicked");
        robot.rotate2CCW();
      }
    else if (e.getActionCommand().equals("Right")) {
        System.out.println("Button6 has been clicked");
        robot.moveRight();
      }
    else if (e.getActionCommand().equals("U")) {
        System.out.println("inv: U has been clicked");
        	robot.invMoveUp();
    }
    else if (e.getActionCommand().equals("L")) {
        System.out.println("inv: L has been clicked");
        robot.invMoveLeft();
    }
    else if (e.getActionCommand().equals("R")) {
        System.out.println("inv: R has been clicked");
        robot.invMoveRight();
    }
    else if (e.getActionCommand().equals("D")) {
        System.out.println("inv: D has been clicked");
        robot.invMoveDown();
    }
    else if (e.getActionCommand().equals("Paint")) {
        System.out.println("Paint has been clicked");
        robot.togglePaint();  
      }
    else if (e.getActionCommand().equals("Mouse")){
    	robot.setMouseMove();
    }
    else if (e.getActionCommand().equals("Clear")){
    	robot.clear();
    }
    else if (e.getActionCommand().equals("Reset")){
    	robot.reset();
    }
  robot.repaint();
  }
}
